package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.SheJiShi;
import com.ysd.util.DBManager;
//实现类
public class SheJiShiDaoImpl {//实体类名+DaoImpl
	public List<SheJiShi> getSheJiShiList() {
		List<SheJiShi> sheJiShiList=new ArrayList<SheJiShi>();
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		
		try {
			st = conn.createStatement();
			rs = st.executeQuery("SELECT *FROM shejishi");
			while(rs.next()) {
				
				int sId = rs.getInt("sheJiShiId");
				String sName = rs.getString("sheJiShiName");
				String stitle = rs.getString("title");
				String simg = rs.getString("img");
				
				SheJiShi sheJiShi = new SheJiShi(sId, sName, stitle, simg);
				sheJiShiList.add(sheJiShi);	
			}
			return sheJiShiList;
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
